<?php

declare(strict_types=1);

namespace SimpleDingTalk\v2;

use SimpleDingTalk\Config;
use Exception;

class Contact
{
    public static function getPersonalInfo(string $unionId)
    {
        $at = Config::getApp()['userAccessToken'];
        $file_path = $at['file_path'];
        $key=AccessToken::setUserToken($unionId);
        if($key<>false){
            return json_decode(file_get_contents($file_path),true)[$key];
        }
        return '';
    }
    public static function invites_infos(string $inviterUserId = '', string $deptId = '')
    {
        $uri = Url::$api['contact'] . '/invites/infos';
        $params = [
            'inviterUserId' => $inviterUserId,
            'deptId' => $deptId
        ];
        $uri = ApiRequest::joinParams($uri, $params);
        return ApiRequest::get($uri);
    }
    public static function dingIndexs()
    {
        $uri = Url::$api['contact'] . '/dingIndexs';

        return ApiRequest::get($uri);
    }
    public static function depts_settings_priorities(bool $enable)
    {
        $uri = Url::$api['contact'] . '/depts/settings/priorities';
        $body = [
            'enable' => $enable
        ];
        return ApiRequest::post($uri, $body);
    }
}
